package org.bf.sms.domain.user;

import java.io.Serializable;
import java.util.Date;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 * 用户信息
 * 
 * @author LiuChang
 * @version 1.0 2010-12-01
 * @since 1.0
 */
public class Account implements Serializable
{
	/** SerialVersionUID */
	private static final long serialVersionUID = 8432728406378769072L;

	/** name */
	private String username;

	/** Password */
	private String password;

	/** CreateDate */
	private Date createDate;

	/** CreateDate */
	private Role role;

	/**
	 * <constructor>
	 */
	public Account()
	{
		super();
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public String toString()
	{
		return ToStringBuilder.reflectionToString(this,
				ToStringStyle.DEFAULT_STYLE);
	}

	/**
	 * {@inheritDoc}
	 * 
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode()
	{
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((this.password == null) ? 0 : this.password.hashCode());
		result = prime * result
				+ ((this.username == null) ? 0 : this.username.hashCode());
		return result;
	}

	/**
	 * {@inheritDoc}
	 * 
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj)
	{
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Account other = (Account) obj;
		if (this.password == null)
		{
			if (other.password != null)
				return false;
		}
		else
			if (!this.password.equals(other.password))
				return false;
		if (this.username == null)
		{
			if (other.username != null)
				return false;
		}
		else
			if (!this.username.equals(other.username))
				return false;
		return true;
	}

	/**
	 * @return the userName
	 */
	public String getUsername()
	{
		return this.username;
	}

	/**
	 * @param userName
	 *            the userName to set
	 */
	public void setUsername(String username)
	{
		this.username = username;
	}

	/**
	 * @return the password
	 */
	public String getPassword()
	{
		return this.password;
	}

	/**
	 * @param password
	 *            the password to set
	 */
	public void setPassword(String password)
	{
		this.password = password;
	}

	/**
	 * @return the createDate
	 */
	public Date getCreateDate()
	{
		if (null != this.createDate)
		{
			return (Date) this.createDate.clone();
		}
		return null;
	}

	/**
	 * @param createDate
	 *            the createDate to set
	 */
	public void setCreateDate(Date createDate)
	{
		this.createDate = createDate;
	}

	/**
	 * @return the role
	 */
	public Role getRole()
	{
		return this.role;
	}

	/**
	 * @param role
	 *            the role to set
	 */
	public void setRole(Role role)
	{
		this.role = role;
	}
}
